<template>
  <div>
    <div>
      <el-input v-model="search" placeholder="请输入名称" size="small" style="width:240px">
        <el-button slot="suffix" type="text" size="small" class="search-button" @click="searchName">
          <i class="el-icon-search"></i>
        </el-button>
      </el-input>
    </div>
    <div>
      <el-table :data="takeTheirList" stripe style="width:100%">
        <el-table-column prop="id" label="ID" align="center" width="40px"></el-table-column>
        <el-table-column prop="realname" label="姓名" align="center"></el-table-column>
        <el-table-column prop="addr" label="自提点地址" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="primary" plain style="padding:3px 5px" @click="select(scope.row)">选择</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getTakeTheir } from '@/api/order'

export default {
  name: 'TakeTheir',
  data() {
    return {
      search: '',
      takeTheirList: [],
      page: '1',
    }
  },
  mounted() {
    this.getTakeTheir();
  },
  methods: {
    /**
     * 选择数据
     */
    select(data) {
      this.$emit('selectRowData',data);
    },
    /**
     * 获取自提点数据
     */
    getTakeTheir() {
      const params = {
        type: '1',
        is_self: '1',
        key: this.$store.state.app.activeApp.saa_key,
        page: this.page,
        limit: 10
      }
      getTakeTheir(params).then(response => {
        if(response.status === 200){
          this.takeTheirList = response.data;
        }else if(response.status === 204){
          this.takeTheirList = [];
        }else{
          this.$message.error(response.message);
        }
      })
    },
    searchName(){
      console.log(this.search);
    }
  },
}
</script>